import { ref } from 'vue';
const curYear = new Date().getFullYear().toString();
const year = ref(curYear);
function setYear(data: any = curYear) {
  year.value = data;
  //  对 year 进行缓存
  localStorage.setItem('year', data);
}

export function getYear() {
  const data = localStorage.getItem('year');
  if(data) {
    year.value = data
  } else {
    setYear();
  }

  return year.value;
}

export function useYear(): any[] {
  return [ year, setYear ];
}